package com.brzjomo.secretiveworld.world.gen;

import com.brzjomo.secretiveworld.init.ModBlocks;

import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;

public class ModOreGen {
	@SuppressWarnings("rawtypes")
	public static void oreGen() {
		for (Biome biome : ForgeRegistries.BIOMES) {
			boolean isMainWorld  = (biome != Biomes.THE_VOID) && (biome != Biomes.NETHER) && (biome != Biomes.THE_END) && (biome != Biomes.END_BARRENS) && (biome != Biomes.END_HIGHLANDS) && (biome != Biomes.END_MIDLANDS) && (biome != Biomes.SMALL_END_ISLANDS);
			if (isMainWorld == true) {
				//CountRangeConfig(count, bottomOffset, topOffect, maximum),count大概为矿石的生成次数;maximum为矿石生成的最高层数,这个值必须大于等于count与topOffect的和
				ConfiguredPlacement copper = Placement.COUNT_RANGE.configure(new CountRangeConfig(25, 5, 5, 55));
				ConfiguredPlacement silver = Placement.COUNT_RANGE.configure(new CountRangeConfig(10, 5, 5, 25));
				//OreFeatureConfig(target, state, size)中的size为单个矿石堆的最大规模
				biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, ModBlocks.COPPER_ORE.get().getDefaultState(), 8)).withPlacement(copper));
				biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, ModBlocks.SILVER_ORE.get().getDefaultState(), 6)).withPlacement(silver));
			}
		}
	}
}
